﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EFCore1
{
  internal class BookConfig : IEntityTypeConfiguration<Book>
  {
    /// <summary>
    /// 通过Fluent API的方式配置
    /// </summary>
    /// <param name="builder"></param>
    public void Configure(EntityTypeBuilder<Book> builder)
    {
      builder.ToTable("T_Books");
      builder.Property(x => x.Title).HasMaxLength(50).IsRequired();
      builder.Property(x=>x.AuthorName).HasMaxLength(20).IsRequired();

    }
  }
}
